﻿using Capstone.ViewModels;
using System.Collections.Generic;
using System.ComponentModel;
using Xamarin.Forms;
using Capstone.Models;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Capstone.Services;
using System.Runtime.CompilerServices;
using System.IO;
using System.Text;
using System.Reflection;
using System.Net.Http;
using Newtonsoft.Json;
using System.Configuration;
using Capstone.Properties;
using Xamarin.Essentials;

namespace Capstone.Views
{
    public partial class StoolQualityPage : ContentPage
    {
        private string itemId;
        private string text;
        private string description;
        public string Id { get; set; }

        private int length;
        private string frequency;
        public string loadId;
        private string[] symptoms;
        public string CurrentId;
        public Item CurrentItem;
        public List<string> typeOptions;

        public List<int> timeOptions1;
        public List<int> timeOptions2;
        public void Save_Settings(string save_key, string save_value, string day_id)
        {
            Preferences.Set(save_key, save_value, day_id);
        }
        public void ServerSend(object sender, EventArgs args)
        {
            Send();
        }

        public async void Send()
        {
            int customInt = 0;
            HttpClient client = new HttpClient();

            string data = "[{\"record_id\":\"" + CurrentId + "\", \"stool_quality_q0\":\"" + Preferences.Get("stool_q0", "value", CurrentId) + "\"";

            Console.WriteLine(data);
            if (Preferences.Get("stool_q0", "value", CurrentId) == "1")
            {
                data += ", \"stool_quality_time_h\":\"" + Preferences.Get("stool_h", "value", CurrentId) + "\"";
                data += ", \"stool_quality_time_min\":\"" + Preferences.Get("stool_min", "value", CurrentId) + "\"";
                Console.WriteLine("time" + Preferences.Get("stool_min", "value", CurrentId));

                if (Preferences.Get("stool_type", "value", CurrentId).Contains("1"))
                {
                    data += ", \"stool_quality_type___1\":\"" + "1" + "\"";
                }
                else data += ", \"stool_quality_type___1\":\"" + "0" + "\"";
                if (Preferences.Get("stool_type", "value", CurrentId).Contains("2"))
                {
                    data += ", \"stool_quality_type___2\":\"" + "1" + "\"";
                }
                else data += ", \"stool_quality_type___2\":\"" + "0" + "\"";
                if (Preferences.Get("stool_type", "value", CurrentId).Contains("3"))
                {
                    data += ", \"stool_quality_type___3\":\"" + "1" + "\"";
                }
                else data += ", \"stool_quality_type___3\":\"" + "0" + "\"";
                if (Preferences.Get("stool_type", "value", CurrentId).Contains("4"))
                {
                    data += ", \"stool_quality_type___4\":\"" + "1" + "\"";
                }
                else data += ", \"stool_quality_type___4\":\"" + "0" + "\"";
                if (Preferences.Get("stool_type", "value", CurrentId).Contains("5"))
                {
                    data += ", \"stool_quality_type___5\":\"" + "1" + "\"";
                }
                else data += ", \"stool_quality_type___5\":\"" + "0" + "\"";
                if (Preferences.Get("stool_type", "value", CurrentId).Contains("6"))
                {
                    data += ", \"stool_quality_type___6\":\"" + "1" + "\"";
                }
                else data += ", \"stool_quality_type___6\":\"" + "0" + "\"";
                if (Preferences.Get("stool_type", "value", CurrentId).Contains("7"))
                {
                    data += ", \"stool_quality_type___7\":\"" + "1" + "\"";
                }
                else data += ", \"stool_quality_type___7\":\"" + "0" + "\"";
                Console.WriteLine("stool_type" + Preferences.Get("stool_type", "value", CurrentId));

                for (int i = 0; i < 11; i++)
                {
                    Console.WriteLine("test " + i);
                    if (CurrentItem.Symptoms.Length > i)
                    {
                        // if (CurrentItem.Symptoms[i] == Properties.Resources.StoolQuestions1)
                        if (CurrentItem.Symptoms[i].Contains(Properties.Resources.StoolQuestions1))
                        {
                            data += ", \"stool_quality_q1\":\"" + Preferences.Get("stool_q1", "", CurrentId) + "\"";
                            Console.WriteLine(Preferences.Get("stool_q1", "", CurrentId) + "A");
                        }
                        //else if (CurrentItem.Symptoms[i] == Properties.Resources.StoolQuestions2)
                        else if (CurrentItem.Symptoms[i].Contains(Properties.Resources.StoolQuestions2))
                        {
                            data += ", \"stool_quality_q2\":\"" + Preferences.Get("stool_q2", "", CurrentId) + "\"";
                            Console.WriteLine(Preferences.Get("stool_q2", "", CurrentId) + "B");
                        }
                        //else if (CurrentItem.Symptoms[i] == Properties.Resources.StoolQuestions3)
                        else if (CurrentItem.Symptoms[i].Contains(Properties.Resources.StoolQuestions3))
                        {
                            data += ", \"stool_quality_q3\":\"" + Preferences.Get("stool_q3", "", CurrentId) + "\"";
                            Console.WriteLine(Preferences.Get("stool_q3", "", CurrentId) + "C");
                        }
                        //else if (CurrentItem.Symptoms[i] == Properties.Resources.StoolQuestions4)
                        else if (CurrentItem.Symptoms[i].Contains(Properties.Resources.StoolQuestions4))
                        {
                            data += ", \"stool_quality_q4\":\"" + Preferences.Get("stool_q4", "", CurrentId) + "\"";
                            Console.WriteLine(Preferences.Get("stool_q4", "", CurrentId) + "D");
                        }
                        //else if (CurrentItem.Symptoms[i] == (Properties.Resources.StoolQuestions5))
                        else if (CurrentItem.Symptoms[i].Contains(Properties.Resources.StoolQuestions5))
                        {
                            data += ", \"stool_quality_q5\":\"" + Preferences.Get("stool_q5", "", CurrentId) + "\"";
                            Console.WriteLine(Preferences.Get("stool_q5", "", CurrentId) + "E");
                        }
                        //else if (CurrentItem.Symptoms[i] == Properties.Resources.StoolQuestions6)
                        else if (CurrentItem.Symptoms[i].Contains(Properties.Resources.StoolQuestions6))
                        {
                            data += ", \"stool_quality_q6\":\"" + Preferences.Get("stool_q6", "", CurrentId) + "\"";
                            Console.WriteLine(Preferences.Get("stool_q6", "", CurrentId) + "F");
                        }
                        else if (customInt == 0)
                        {
                            Console.WriteLine(CurrentItem.Symptoms[i]);
                            data += ", \"stool_quality_q7\":\"" + Preferences.Get("stool_q7", "", CurrentId) + "\"";
                            customInt++;
                        }
                        else if (customInt == 1)
                        {
                            Console.WriteLine(CurrentItem.Symptoms[i]);
                            data += ", \"stool_quality_q8\":\"" + Preferences.Get("stool_q8", "", CurrentId) + "\"";
                            customInt++;
                        }
                        else if (customInt == 2)
                        {
                            Console.WriteLine(CurrentItem.Symptoms[i]);
                            data += ", \"stool_quality_q9\":\"" + Preferences.Get("stool_q9", "", CurrentId) + "\"";
                            customInt++;
                        }
                        else if (customInt == 3)
                        {
                            Console.WriteLine(CurrentItem.Symptoms[i]);
                            data += ", \"stool_quality_q10\":\"" + Preferences.Get("stool_q10", "", CurrentId) + "\"";
                            customInt++;
                        }
                    }
                }

                data += ", \"stool_quality_information\":\"" + Preferences.Get("information", "", CurrentId) + "\"";
            }
            data += "}]";
            Console.WriteLine(data);

            string data1 = "[{\"record_id\":5, \"stool_quality_study_name\":\"toimii\"}]";
            Console.WriteLine(data1);

            var values = new Dictionary<string, string>
            {
                    { "token", "540E97741AA3EFF280E55B5C9DB1CD6D" },
                    { "content", "record" },
                    { "action", "import" },
                    { "format", "json" },
                    { "overwriteBehavior", "normal" },
                    { "forceAutoNumber", "false" },
                    { "data",  data},
                    { "returnContent", "count" },
                    {"returnFormat", "json" }
            };

            /*var values = new Dictionary<string, string>
             {
                    { "token", "540E97741AA3EFF280E55B5C9DB1CD6D" },  
                    { "action", "rename" },
                    { "content", "record" },
                    { "record", "uusi4" },
                    { "new_record_name", "uusi5" },
                    { "returnFormat", "json" }
             };*/
            var content = new FormUrlEncodedContent(values);
            var response = await client.PostAsync("https://redcap.utu.fi/api/", content);
            var responseString = await response.Content.ReadAsStringAsync();
            if (responseString.Contains("error"))
            {
                Save_Fail.IsVisible = true;
                Save_Success.IsVisible = false;
                Save_Settings("finished", "0", CurrentId);
            }
            else
            {
                Save_Success.IsVisible = true;
                Save_Fail.IsVisible = false;
                Save_Settings("finished", "1", CurrentId);
            }
            Console.WriteLine(responseString);
        }

        public StoolQualityPage()
        {
            InitializeComponent();
            CurrentId = DaysViewModel.day_id;
            loadId = ItemsViewModel.id;

            timeOptions1 = AddDateOptions1();
            timeOptions2 = AddDateOptions2();
            time1.ItemsSource = timeOptions1;
            time2.ItemsSource = timeOptions2;

            typeOptions = AddTypes();

            type.ItemsSource = typeOptions;
            

            List<int> AddDateOptions1()
            {
                List<int> options1 = new List<int>();
                for (int i = 0; i < 24; i++)
                {
                    options1.Add(i);
                }
                return options1;
            }
            List<int> AddDateOptions2()
            {
                List<int> options2 = new List<int>();
                for (int i = 0; i < 60; i++)
                {
                    options2.Add(i);
                }
                return options2;
            }
            List<string> AddTypes()
            {
                List<string> options = new List<string>();
                options.Add(Properties.Resources.StoolType1);
                options.Add(Properties.Resources.StoolType2);
                options.Add(Properties.Resources.StoolType3);
                options.Add(Properties.Resources.StoolType4);
                options.Add(Properties.Resources.StoolType5);
                options.Add(Properties.Resources.StoolType6);
                options.Add(Properties.Resources.StoolType7);
                return options;
            }

            LoadItemId(loadId);
            Console.WriteLine("Id test: " + CurrentId);

            string placeholder = "";
            placeholder = Preferences.Get("stool_q0", "value", CurrentId);
            Console.WriteLine("test: " + placeholder);
            if (placeholder == "1")
            {
                RB2A2.IsChecked = true;
                RB2B2.IsChecked = false;
            }
            if (placeholder == "0")
            {
                RB2A2.IsChecked = false;
                RB2B2.IsChecked = true;
            }

            placeholder = Preferences.Get("stool_h", "value", CurrentId);
            Console.WriteLine("time_h:" + placeholder);
            if (placeholder == "0" || placeholder == "1" || placeholder == "2" || placeholder == "3" || placeholder == "4" || placeholder == "5" || placeholder == "6" || placeholder == "7" || placeholder == "8" || placeholder == "9" || placeholder == "10" || placeholder == "11" || placeholder == "13" || placeholder == "14" || placeholder == "15" || placeholder == "16" || placeholder == "17" || placeholder == "18" || placeholder == "19" || placeholder == "20" || placeholder == "21" || placeholder == "22" || placeholder == "23")
                
            {
                time1.SelectedIndex = Int32.Parse(placeholder);
            }
            else
            {
                time1.SelectedIndex = -1;
            }
            placeholder = Preferences.Get("stool_min", "value", CurrentId);
            Console.WriteLine("time_min:" + placeholder);
            if (placeholder == "0" || placeholder == "1" || placeholder == "2" || placeholder == "3" || placeholder == "4" || placeholder == "5" || placeholder == "6" || placeholder == "7" || placeholder == "8" || placeholder == "9" || placeholder == "10" || placeholder == "11" || placeholder == "13" || placeholder == "14" || placeholder == "15" || placeholder == "16" || placeholder == "17" || placeholder == "18" || placeholder == "19" || placeholder == "20" || placeholder == "21" || placeholder == "22" || placeholder == "23" || placeholder == "24" || placeholder == "25" || placeholder == "26" || placeholder == "27" || placeholder == "28" || placeholder == "29" || placeholder == "30" || placeholder == "31" || placeholder == "32" || placeholder == "33" || placeholder == "34" || placeholder == "35" || placeholder == "36" || placeholder == "37" || placeholder == "38" || placeholder == "39" || placeholder == "40" || placeholder == "41" || placeholder == "42" || placeholder == "43" || placeholder == "44" || placeholder == "45" || placeholder == "46" || placeholder == "47" || placeholder == "48" || placeholder == "49" || placeholder == "50" || placeholder == "51" || placeholder == "52" || placeholder == "53" || placeholder == "54" || placeholder == "55" || placeholder == "56" || placeholder == "57" || placeholder == "58" || placeholder == "59")
    
            {
                time2.SelectedIndex = Int32.Parse(placeholder);
            }
            else
            {
                time2.SelectedIndex = -1;
            }

            placeholder = Preferences.Get("stool_type", "value", CurrentId);
            Console.WriteLine("stool_type1 " + placeholder);
            type.SelectedIndices = new List<int> { };
            Console.WriteLine("stool_type2 " + placeholder);
            if (placeholder.Contains("Type"))
            {
                
                if (placeholder.Contains("Type 1"))
                {
                    type.SelectedIndices.Add(0);
                }
                if (placeholder.Contains("Type 2"))
                {
                    type.SelectedIndices.Add(1);
                }
                if (placeholder.Contains("Type 3"))
                {
                    type.SelectedIndices.Add(2);
                }
                if (placeholder.Contains("Type 4"))
                {
                    type.SelectedIndices.Add(3);
                }
                if (placeholder.Contains("Type 5"))
                {
                    type.SelectedIndices.Add(4);
                }
                if (placeholder.Contains("Type 6"))
                {
                    type.SelectedIndices.Add(5);
                }
                if (placeholder.Contains("Type 7"))
                {
                    type.SelectedIndices.Add(6);
                }
                type.Text = placeholder;
            }
            Console.WriteLine("stool_type3 " + placeholder);
            //{
            //    type.SelectedIndex = Int32.Parse(placeholder);
            //}
            //else
            //{
            //    type.SelectedIndex = -1;
            //}

            placeholder = Preferences.Get("stool_q1", "", CurrentId); 
            Console.WriteLine("stool_q1 " + placeholder);
            if (placeholder == "1")
            {
                S1A2.IsChecked = true;
                S1B2.IsChecked = false;
            }
            else if (placeholder == "0")
            {
                S1A2.IsChecked = false;
                S1B2.IsChecked = true;
            }
            placeholder = Preferences.Get("stool_q2", "", CurrentId);
            Console.WriteLine("stool_q2 " + placeholder);
            if (placeholder == "1")
            {
                S2A2.IsChecked = true;
                S2B2.IsChecked = false;
            }
            else if (placeholder == "0")
            {
                S2A2.IsChecked = false;
                S2B2.IsChecked = true;
            }
            placeholder = Preferences.Get("stool_q3", "", CurrentId);
            Console.WriteLine("stool_q3 " + placeholder);
            if (placeholder == "1")
            {
                S3A2.IsChecked = true;
                S3B2.IsChecked = false;
            }
            else if (placeholder == "0")
            {
                S3A2.IsChecked = false;
                S3B2.IsChecked = true;
            }
            placeholder = Preferences.Get("stool_q4", "", CurrentId);
            Console.WriteLine("stool_q4 " + placeholder);
            if (placeholder == "1")
            {
                S4A2.IsChecked = true;
                S4B2.IsChecked = false;
            }
            else if (placeholder == "0")
            {
                S4A2.IsChecked = false;
                S4B2.IsChecked = true;
            }
            placeholder = Preferences.Get("stool_q5", "", CurrentId);
            Console.WriteLine("stool_q5 " + placeholder);
            if (placeholder == "1")
            {
                S5A2.IsChecked = true;
                S5B2.IsChecked = false;
            }
            else if (placeholder == "0")
            {
                S5A2.IsChecked = false;
                S5B2.IsChecked = true;
            }
            placeholder = Preferences.Get("stool_q6", "", CurrentId);
            Console.WriteLine("stool_q6 " + placeholder);
            if (placeholder == "1")
            {
                S6A2.IsChecked = true;
                S6B2.IsChecked = false;
            }
            else if (placeholder == "0")
            {
                S6A2.IsChecked = false;
                S6B2.IsChecked = true;
            }
            placeholder = Preferences.Get("stool_q7", " ", CurrentId);
            Console.WriteLine("stool_q7 " + placeholder);
            if (placeholder == "1")
            {
                S7A2.IsChecked = true;
                S7B2.IsChecked = false;
            }
            else if (placeholder == "0")
            {
                S7A2.IsChecked = false;
                S7B2.IsChecked = true;
            }
            placeholder = Preferences.Get("stool_q8", " ", CurrentId);
            Console.WriteLine("stool_q8 " + placeholder);
            if (placeholder == "1")
            {
                S8A2.IsChecked = true;
                S8B2.IsChecked = false;
            }
            else if (placeholder == "0")
            {
                S8A2.IsChecked = false;
                S8B2.IsChecked = true;
            }
            placeholder = Preferences.Get("stool_q9", " ", CurrentId);
            Console.WriteLine("stool_q9" + placeholder);
            if (placeholder == "1")
            {
                S9A2.IsChecked = true;
                S9B2.IsChecked = false;
            }
            else if (placeholder == "0")
            {
                S9A2.IsChecked = false;
                S9B2.IsChecked = true;
            }
            placeholder = Preferences.Get("stool_q10", " ", CurrentId);
            Console.WriteLine("stool_q10 " + placeholder);
            if (placeholder == "1")
            {
                S10A2.IsChecked = true;
                S10B2.IsChecked = false;
            }
            else if (placeholder == "0")
            {
                S10A2.IsChecked = false;
                S10B2.IsChecked = true;
            }

            placeholder = Preferences.Get("information", "", CurrentId);
            Console.WriteLine("information " + placeholder);
            if (placeholder != null)
            {
                end.Text = (placeholder);
            }
            else
            {
                end.BindingContext = -1;
            }
        }

        private void RB2A2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q0", "1", CurrentId);
            time_text.IsVisible = true;
            time1.IsVisible = true;
            time2.IsVisible = true;
            label1.IsVisible = true;
            label2.IsVisible = true;
            type_text.IsVisible = true;
            type.IsVisible = true;
            type00.IsVisible = true;
            end.IsVisible = true;

            type1.IsVisible = false;
            type3.IsVisible = false;
            type4.IsVisible = false;
            type5.IsVisible = false;
            type6.IsVisible = false;
            type7.IsVisible = false;
            type11.IsVisible = false;
            type22.IsVisible = false;
            type33.IsVisible = false;
            type44.IsVisible = false;
            type55.IsVisible = false;
            type66.IsVisible = false;
            type77.IsVisible = false;

            if (CurrentItem.Symptoms.Length == 1)
            {

                if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions1))
                {
                    Symptom1A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom1A.IsVisible = true;
                    S1A2.IsVisible = true;
                    S1B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }
            }
            else if (CurrentItem.Symptoms.Length == 2)
            {
                if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions1))
                {
                    Symptom1A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom1A.IsVisible = true;
                    S1A2.IsVisible = true;
                    S1B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }
            }
            else if (CurrentItem.Symptoms.Length == 3)
            {
                if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions1))
                {
                    Symptom1A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom1A.IsVisible = true;
                    S1A2.IsVisible = true;
                    S1B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }
            }
            else if (CurrentItem.Symptoms.Length == 4)
            {
                if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions1))
                {
                    Symptom1A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom1A.IsVisible = true;
                    S1A2.IsVisible = true;
                    S1B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }
            }
            else if (CurrentItem.Symptoms.Length == 5)
            {
                if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions1))
                {
                    Symptom1A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom1A.IsVisible = true;
                    S1A2.IsVisible = true;
                    S1B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[4].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[4].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }
            }
            else if (CurrentItem.Symptoms.Length == 6)
            {
                if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions1))
                {
                    Symptom1A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom1A.IsVisible = true;
                    S1A2.IsVisible = true;
                    S1B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[4].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[4].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[5].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }
            }
            else if (CurrentItem.Symptoms.Length == 7)
            {
                if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions1))
                {
                    Symptom1A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom1A.IsVisible = true;
                    S1A2.IsVisible = true;
                    S1B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[4].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[4].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[5].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[6] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[6] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[6] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[6] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }
            }
            else if (CurrentItem.Symptoms.Length == 8)
            {

                if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions1))
                {
                    Symptom1A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom1A.IsVisible = true;
                    S1A2.IsVisible = true;
                    S1B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[4].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[4].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[5].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[6] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[6] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[6] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[6] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[7] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[7] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else
                {
                    Symptom8A.Text = CurrentItem.Symptoms[7] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
            }
            else if (CurrentItem.Symptoms.Length == 9)
            {
                if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions1))
                {
                    Symptom1A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom1A.IsVisible = true;
                    S1A2.IsVisible = true;
                    S1B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[0].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[0] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions2))
                {
                    Symptom2A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom2A.IsVisible = true;
                    S2A2.IsVisible = true;
                    S2B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[1].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[1] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions3))
                {
                    Symptom3A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom3A.IsVisible = true;
                    S3A2.IsVisible = true;
                    S3B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[2].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[2] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions4))
                {
                    Symptom4A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom4A.IsVisible = true;
                    S4A2.IsVisible = true;
                    S4B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[3].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[3] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[4].Contains(Properties.Resources.StoolQuestions5))
                {
                    Symptom5A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom5A.IsVisible = true;
                    S5A2.IsVisible = true;
                    S5B2.IsVisible = true;
                }
                else if (CurrentItem.Symptoms[4].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[4] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (CurrentItem.Symptoms[5].Contains(Properties.Resources.StoolQuestions6))
                {
                    Symptom6A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom6A.IsVisible = true;
                    S6A2.IsVisible = true;
                    S6B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[5] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[6] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[6] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else if (S7A2.IsVisible)
                {
                    Symptom8A.Text = CurrentItem.Symptoms[6] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }
                else
                {
                    Symptom7A.Text = CurrentItem.Symptoms[6] + "?";
                    Symptom7A.IsVisible = true;
                    S7A2.IsVisible = true;
                    S7B2.IsVisible = true;
                }

                if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[7] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else if (S7A2.IsVisible && S8A2.IsVisible)
                {
                    Symptom9A.Text = CurrentItem.Symptoms[7] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
                else
                {
                    Symptom8A.Text = CurrentItem.Symptoms[7] + "?";
                    Symptom8A.IsVisible = true;
                    S8A2.IsVisible = true;
                    S8B2.IsVisible = true;
                }

                if (S7A2.IsVisible && S8A2.IsVisible && S9A2.IsVisible)
                {
                    Symptom10A.Text = CurrentItem.Symptoms[8] + "?";
                    Symptom10A.IsVisible = true;
                    S10A2.IsVisible = true;
                    S10B2.IsVisible = true;
                }
                else
                {
                    Symptom9A.Text = CurrentItem.Symptoms[8] + "?";
                    Symptom9A.IsVisible = true;
                    S9A2.IsVisible = true;
                    S9B2.IsVisible = true;
                }
            }
            else if (CurrentItem.Symptoms.Length == 10)
            {
                Symptom1A.Text = CurrentItem.Symptoms[0];
                Symptom1A.IsVisible = true;
                S1A2.IsVisible = true;
                S1B2.IsVisible = true;

                Symptom2A.Text = CurrentItem.Symptoms[1];
                Symptom2A.IsVisible = true;
                S2A2.IsVisible = true;
                S2B2.IsVisible = true;

                Symptom3A.Text = CurrentItem.Symptoms[2];
                Symptom3A.IsVisible = true;
                S3A2.IsVisible = true;
                S3B2.IsVisible = true;

                Symptom4A.Text = CurrentItem.Symptoms[3];
                Symptom4A.IsVisible = true;
                S4A2.IsVisible = true;
                S4B2.IsVisible = true;

                Symptom5A.Text = CurrentItem.Symptoms[4];
                Symptom5A.IsVisible = true;
                S5A2.IsVisible = true;
                S5B2.IsVisible = true;

                Symptom6A.Text = CurrentItem.Symptoms[5];
                Symptom6A.IsVisible = true;
                S6A2.IsVisible = true;
                S6B2.IsVisible = true;

                Symptom7A.Text = CurrentItem.Symptoms[6];
                Symptom7A.IsVisible = true;
                S7A2.IsVisible = true;
                S7B2.IsVisible = true;

                Symptom8A.Text = CurrentItem.Symptoms[7];
                Symptom8A.IsVisible = true;
                S8A2.IsVisible = true;
                S8B2.IsVisible = true;

                Symptom9A.Text = CurrentItem.Symptoms[8];
                Symptom9A.IsVisible = true;
                S9A2.IsVisible = true;
                S9B2.IsVisible = true;

                Symptom10A.Text = CurrentItem.Symptoms[9];
                Symptom10A.IsVisible = true;
                S10A2.IsVisible = true;
                S10B2.IsVisible = true;
            }
        }

        private void RB2B2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q0", "0", CurrentId);
            time_text.IsVisible = false;
            time1.IsVisible = false;
            time2.IsVisible = false;
            label1.IsVisible = false;
            label2.IsVisible = false;
            type_text.IsVisible = false;
            type.IsVisible = false;
            type00.IsVisible = false;
            end.IsVisible = false;

            type1.IsVisible=false;
            type3.IsVisible=false;
            type4.IsVisible = false;
            type5.IsVisible = false;
            type6.IsVisible = false;
            type7.IsVisible = false;
            type11.IsVisible = false;
            type22.IsVisible = false;
            type33.IsVisible=false;
            type44.IsVisible = false;
            type55.IsVisible = false;
            type66.IsVisible = false;
            type77.IsVisible = false;
            


            S1A2.IsChecked = false;
            S1B2.IsChecked = false;
            S2A2.IsChecked = false;
            S2B2.IsChecked = false;
            S3A2.IsChecked = false;
            S3B2.IsChecked = false;
            S4A2.IsChecked = false;
            S4B2.IsChecked = false;
            S5A2.IsChecked = false;
            S5B2.IsChecked = false;
            S6A2.IsChecked = false;
            S6B2.IsChecked = false;
            S7A2.IsChecked = false;
            S7B2.IsChecked = false;
            S8A2.IsChecked = false;
            S8B2.IsChecked = false;
            S9A2.IsChecked = false;
            S9B2.IsChecked = false;
            S10A2.IsChecked = false;
            S1A2.IsVisible = false;
            S1B2.IsVisible = false;
            S2A2.IsVisible = false;
            S2B2.IsVisible = false;
            S3A2.IsVisible = false;
            S3B2.IsVisible = false;
            S4A2.IsVisible = false;
            S4B2.IsVisible = false;
            S5A2.IsVisible = false;
            S5B2.IsVisible = false;
            S6A2.IsVisible = false;
            S6B2.IsVisible = false;
            S7A2.IsVisible = false;
            S7B2.IsVisible = false;
            S8A2.IsVisible = false;
            S8B2.IsVisible = false;
            S9A2.IsVisible = false;
            S9B2.IsVisible = false;
            S10A2.IsVisible = false;
            S10B2.IsVisible = false;
            Symptom1A.IsVisible = false;
            Symptom2A.IsVisible = false;
            Symptom3A.IsVisible = false;
            Symptom4A.IsVisible = false;
            Symptom5A.IsVisible = false;
            Symptom6A.IsVisible = false;
            Symptom7A.IsVisible = false;
            Symptom8A.IsVisible = false;
            Symptom9A.IsVisible = false;
            Symptom10A.IsVisible = false;
        }
        private void time1Function(object sender, EventArgs e)
        {
            Save_Settings("stool_h", (time1.SelectedIndex).ToString(), CurrentId);
        }
        private void time2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_min", (time2.SelectedIndex).ToString(), CurrentId);

        }
        private void endFunction(object sender, EventArgs e)
        {
            Save_Settings("information", (end.Text).ToString(), CurrentId);
        }

        private void typeFunction(object sender, EventArgs e)
        {
            
            Save_Settings("stool_type", type.Text, CurrentId);
            string placeholder = Preferences.Get("stool_type", "value", CurrentId);
            Console.WriteLine("stool_type1 " + placeholder);

        }
        private void S1A2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q1", "1", CurrentId);
        }
        private void S1B2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q1", "0", CurrentId);
        }
        private void S2A2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q2", "1", CurrentId);
        }
        private void S2B2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q2", "0", CurrentId);
        }
        private void S3A2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q3", "1", CurrentId);
        }
        private void S3B2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q3", "0", CurrentId);
        }
        private void S4A2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q4", "1", CurrentId);
        }
        private void S4B2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q4", "0", CurrentId);
        }
        private void S5A2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q5", "1", CurrentId);
        }
        private void S5B2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q5", "0", CurrentId);
        }
        private void S6A2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q6", "1", CurrentId);
        }
        private void S6B2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q6", "0", CurrentId);
        }
        private void S7A2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q7", "1", CurrentId);
        }
        private void S7B2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q7", "0", CurrentId);
        }
        private void S8A2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q8", "1", CurrentId);
        }
        private void S8B2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q8", "0", CurrentId);
        }
        private void S9A2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q9", "1", CurrentId);
        }
        private void S9B2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q9", "0", CurrentId);
        }
        private void S10A2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q10", "1", CurrentId);
        }
        private void S10B2Function(object sender, EventArgs e)
        {
            Save_Settings("stool_q10", "0", CurrentId);
        }
        protected bool SetProperty<T>(ref T backingStore, T value,
            [CallerMemberName] string propertyName = "",
            Action onChanged = null)
        {
            if (EqualityComparer<T>.Default.Equals(backingStore, value))
                return false;

            backingStore = value;
            onChanged?.Invoke();
            OnPropertyChanged(propertyName);
            return true;
        }
        public string Text
        {
            get
            {
                return text;
            }

            set
            {
                SetProperty(ref text, value);
            }
        }
        public int Length
        {
            get => length;
            set => SetProperty(ref length, value);
        }

        public string Frequency
        {
            get => frequency;
            set => SetProperty(ref frequency, value);
        }
        public string Description
        {
            get => description;
            set => SetProperty(ref description, value);
        }

        public string ItemId
        {
            get
            {
                return itemId;
            }
            set
            {
                itemId = value;
                LoadItemId(value);
            }

        }
        public string[] Symptoms
        {
            get => symptoms;
            set => SetProperty(ref symptoms, value);
        }

        public async void LoadItemId(string itemId)
        {
            try
            {
                var item = await DependencyService.Get<IDataStore<Item>>().GetItemAsync(itemId);
                Id = item.Id;
                Text = item.Text;
                Description = item.Description;
                Frequency = item.Frequency;
                Length = item.Length;
                Symptoms = item.Symptoms;
                CurrentItem = item;
            }
            catch (Exception)
            {
                Debug.WriteLine("Failed to Load Item");
            }
        }
    }
}